package com.zbkj.admin.pub;

import com.zbkj.common.response.CommonResult;
import com.zbkj.service.service.mszs.QimoWebCallService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 接收-来自七陌的按键信息
 * @author lingfe
 */
@Slf4j
@RestController("QimoWebCallAdminController")
@RequestMapping("api/public/receive/key")
@Api(tags = "七陌接口")
public class QimoWebCallController {

    @Autowired
    private QimoWebCallService qimoWebCallService;

    @ApiOperation(value = "向七陌发起拨号请求-传递参数")
    @RequestMapping(value = "/setParam", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jdName",value = "酒店信息"),
            @ApiImplicitParam(name = "phone",value = "被呼手机号")
    })
    public CommonResult<Object> setParam(@RequestParam("jdName")String jdName, @RequestParam("phone")String phone){
        qimoWebCallService.qimoCallRequestSet(phone,jdName);
        return CommonResult.success();
    }

    @ApiOperation(value = "向七陌发起拨号请求(默认配置)")
    @RequestMapping(value = "/defaultConfig", method = RequestMethod.GET)
    public CommonResult<Object> defaultConfig(){
        qimoWebCallService.qimoCallRequestSetTestDefault();
        return CommonResult.success();
    }

    @ApiOperation(value = "接收-来自七陌的按键信息")
    @RequestMapping(value = "/receiveKey", method = RequestMethod.GET)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key",value = "按键信息，如：1、2、3",required = true),
            @ApiImplicitParam(name = "phone",value = "用户手机号",required = true),
            @ApiImplicitParam(name = "order6",value = "6位订单号")
    })
    public CommonResult<Object> receiveKey(
            @RequestParam("key")String key,
            @RequestParam("phone")String phone,
            @RequestParam(value = "order6",required = false)String order6){
        System.out.println("key = " + key);
        System.out.println("phone = " + phone);
        System.out.println("order6 = " + order6);
        qimoWebCallService.chuliQimoYiwuData(key, phone,order6);
        return CommonResult.success();
    }
}
